from insts.inst import BranchInstruction
from jthread.frame import JFrame


class GOTO(BranchInstruction):

    def __init__(self, opcode):
        super().__init__(opcode)

    def branch(self, frame: JFrame):
        pc = frame.getJThread().getPC()
        nextPc = pc + self.offset
        frame.setNextPc(nextPc)

    def execute(self, frame: JFrame):
        self.branch(frame)


